/**
 *
 * @authors wangmin@fulan.com.cn
 * @date    2016-11-29 20:20:36
 * @version 1.0.0
 * 自助查勘h5版基础脚本类
 */

var survey = survey || {};
! function($, survey) {
	var sy = survey;

	//关键字
	sy.key = 'survey';

	//版本号
	sy.version = '1.0.0';

	//默认缓存关键字
	sy.cacheKey = 'autoClaim.ss.caseRecord';

	//银行信息缓存关键字
	sy.bankCacheKey = 'autoClaim.ss.bankInfo';

	//检测浏览器是否支持html5新特性
	try {
		var _key = '_cpic_';
		window.localStorage.setItem(_key, '_cpic_');
		window.localStorage.removeItem(_key);
		window.sessionStorage.setItem(_key, '_cpic_');
		window.sessionStorage.removeItem(_key);
	} catch (error) {
		return void alert('请勿使用无痕浏览器访问');
	}

	//获取当前页面的名称
	sy.getPageName = function() {
		var pathname = window.location.pathname;
		var index = pathname.lastIndexOf('\/');
		if (index > 0) {
			pathname = pathname.substr(index + 1);
		}
		return pathname;
	};

	//记录本地日志，用于本地开发和测试
	sy.log = function(msg) {
		msg = typeof msg === 'object' ? JSON.stringify(msg) : msg;
		var _d = new Date();
		var s = _d.getFullYear() + '-' + (_d.getMonth() + 1) + '-' + _d.getDate() + ' ' + _d.getHours() + ':' + _d.getMinutes() + ':' + _d.getSeconds();
		var _tit = '[' + s + '(H5版日志：' + survey.getPageName() + ')] ' + msg;
		sessionStorage._mobile_log = (sessionStorage._mobile_log || '') + _tit + '<br/>';
		var host = window.location.hostname.split('.');
		if (host[0] === 'survey') {
			survey.webLogs(_tit);
		} else {
			console && console.log && console.log(_tit);
		}
	};

	//获取浏览器名称
	sy.getBrowser = function() {
		var agent = window.navigator.userAgent.toLowerCase();
		return agent.indexOf('mqqbrowser') > -1 ? 'qq' : (agent.indexOf('ucbrowser') > -1 ? 'uc' : (agent.indexOf('micromessenger') > -1 ? 'wechat' : ''));
	}();

	//获取运行平台名称
	sy.getPlatform = function() {
		var plat = window.navigator.platform.toString().toLowerCase();
		return plat.indexOf("linux") > -1 ? 'Android' : (plat.indexOf("iphone") > -1 ? 'iOS' : '');
	}();

	//重定向，页面跳转
	sy.redirection = function(path) {
		window.location.replace(path || '/pages/404.html');
	};

	//获取地址栏参数
	sy.getHash = function(key, url) {
		var hash;
		if (!!url) {
			hash = url.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
			hash = (hash == url) ? "" : hash;
		} else {
			hash = self.location.search;
		}

		hash = "" + hash;
		hash = hash.replace(/^[?#]/, '');
		hash = "&" + hash;
		var val = hash.match(new RegExp("[\&]" + key + "=([^\&]+)", "i"));
		if (!val || val.length < 1) {
			return null;
		} else {
			return decodeURIComponent(val[1]);
		}
	};

	//自适应移动设备
	sy.adaptivePhone = function() {
		var content = 'width=750, user-scalable=no';
		var meta = document.createElement('meta');
		meta.setAttribute('name', 'viewport');
		if (/Android (\d+\.\d+)/.test(navigator.userAgent)) {
			var version = parseFloat(RegExp.$1);
			content = 'width=750';
			if (version > 2.3) {
				var phoneScale = parseInt(window.screen.width) / 750;
				content = 'width=750, minimum-scale = ' + phoneScale + ', maximum-scale = ' + phoneScale + '';
			}
		}
		meta.setAttribute('content', content);
		document.head.appendChild(meta);
	};

	//设置本地缓存
	sy.setLocalStorage = function(key, value, isJson) {
		if (window.localStorage) {
			if (isJson) {
				value = JSON.stringify(value);
			}
			window.localStorage[key] = value;
		}
	};

	//获取本地缓存
	sy.getLocalStorage = function(key, isJson) {
		if (window.localStorage) {
			var value = window.localStorage[key] || "";
			if (isJson && value) {
				value = JSON.parse(value);
			}
			return value;
		}
		return '';
	};

	//清除本地缓存
	sy.removelocalStorage = function(key) {
		if (window.localStorage) {
			window.localStorage.removeItem(key);
		}
	};

	//设置运行时缓存setSessionStorage
	sy.setSessionStorage = function(key, content, isJson) {
		if (window.sessionStorage) {
			if (isJson) {
				content = JSON.stringify(content);
			}
			window.sessionStorage[key] = content;
		}
	};

	//获取运行时缓存getSessionStorage
	sy.getSessionStorage = function(key, isJson) {
		if (window.sessionStorage) {
			var value = window.sessionStorage[key] || '';
			if (isJson && value) {
				value = JSON.parse(value);
			}
			return value;
		}
		return '';
	};

	//清除运行时缓存removeSessionStorage
	sy.removeSessionStorage = function(key) {
		if (window.sessionStorage) {
			window.sessionStorage.removeItem(key);
		}
	};

	//增加cookie
	sy.addCookie = function(name, value, expiresHours) {
		var cookieString = name + "=" + escape(value);
		//判断是否设置过期时间
		if (expiresHours) {
			if (expiresHours > 0) {
				var date = new Date();
				date.setTime(date.getTime + expiresHours * 3600 * 1000);
				cookieString = cookieString + "; expires=" + date.toGMTString();
			}
		}
		document.cookie = cookieString;
	};

	//获取cookie
	sy.getCookie = function(name) {
		var strCookie = document.cookie;
		var arrCookie = strCookie.split("; ");
		for (var i = 0; i < arrCookie.length; i++) {
			var arr = arrCookie[i].split("=");
			if (arr[0] == name) return arr[1];
		}
		return '';
	};

	//删除cookie
	sy.deleteCookie = function(name) {
		var date = new Date();
		date.setTime(date.getTime() - 10000);
		document.cookie = name + "=v; expires=" + date.toGMTString();
	};

	//文件是否存在
	sy.isInclude = function(path) {
		var index = path.lastIndexOf('\/');
		var name = index > 0 ? path.substr(index + 1) : path;
		var css = /css$/i.test(name);
		var tag = 'link';
		var pt = 'href';
		if (!css) {
			tag = 'script';
			pt = 'src';
		}

		var elements = document.getElementsByTagName(tag);
		for (var i = 0; i < elements.length; i++) {
			if (elements[i][pt].indexOf(name) > -1) {
				return true;
			}
		}
		return [false, css];
	};

	//动态加载文件，只能加载CSS和js文件
	sy.loadFiles = function(path, callback) {
		if (!path) {
			$.isFunction(callback) && callback({
				status: false,
				error: '请传入有效的路径'
			});
			return;
		}

		var exist = survey.isInclude(path);
		if (typeof exist === 'boolean' && exist) {
			$.isFunction(callback) && callback({
				status: true
			});
			return;
		}
		var js = !exist[1];
		var el = document.getElementsByTagName('body')[0];
		var node = document.createElement('script');
		path += (path.indexOf('?') > -1 ? '&' : '?') + new Date().getTime();
		if (js) {
			node.type = 'text/javascript';
			node.src = path;
		} else {
			el = document.getElementsByTagName('head')[0];
			node = document.createElement('link');
			node.rel = 'stylesheet';
			node.type = 'text/css';
			node.href = path;
		}
		//所有浏览器加载css都会走onload方法
		node.onload = function() {
			if (js) {
				survey.log(path + '文件加载成功');
				$.isFunction(callback) && callback({
					status: true
				});
			} else {
				var _n = 0;
				var _poll = function(node, callback) {
					var isLoaded = false;
					if (/webkit/i.test(navigator.userAgent)) {
						//webkit
						if (node.sheet) {
							isLoaded = true;
						}
					} else if (node.sheet) {
						// for Firefox
						try {
							if (node.sheet.cssRules) {
								isLoaded = true;
							}
						} catch (ex) {
							// NS_ERROR_DOM_SECURITY_ERR
							if (ex.code === 1000) {
								isLoaded = true;
							}
						}
					}
					if (isLoaded) {
						survey.log(path + '文件加载成功');
						$.isFunction(callback) && callback({
							status: true
						});
					} else {
						if (++_n > 10) {
							survey.log(path + '文件加载失败');
							callback({
								status: false,
								error: 'CSS文件加载失败，请重试...'
							});
						} else {
							window.setTimeout(function() {
								_poll(node, callback);
							}, 100);
						}
					}
				};

				_poll(node, callback);
			}
		};
		node.onerror = function(e) {
			survey.log(path + '文件加载失败');

		};

		el.appendChild(node);
	};

	//高德地图地址
	sy.gaodeMapsPath = window.location.protocol + '//webapi.amap.com/maps?v=1.3&key=585d5dd703232d5bf2311e7b03882824';

	//加载高德地图各种内部插件
	sy.loadGaodeMaps = function(callback) {
		survey.loadFiles(survey.gaodeMapsPath, function(response) {
			if (!response.status) {
				survey.log(response.error);
				callback(false);
				return;
			}

			var n = 0;
			var t = window.setInterval(function() {
				n++;
				if (window.AMap && (AMap.service || AMap.Map)) {
					window.clearInterval(t);
					t = null;
					callback(true);
				}
				//如果5s后还未获取成功，则返回空
				if (n > 10) {
					window.clearInterval(t);
					t = null;
					survey.log('获取具体地理位置失败返回信息：5s后都没有找到AMap.service');
					callback(false);
				}
			}, 500);
		});
	};

	//根据经纬度从高德地图上获取具体地址
	sy.getAddress = function(position, callback) {
		survey.loadGaodeMaps(function(response) {
			if (!response) {
				callback('');
				return;
			}
			AMap.service('AMap.Geocoder', function() {
				//回调函数
				//实例化Geocoder
				geocoder = new AMap.Geocoder({
					city: "010" //城市，默认：“全国”
				});
				geocoder.getAddress([position.longitude, position.latitude], function(status, result) {
					survey.log('获取具体地理位置返回信息：' + JSON.stringify(result));
					if (status === 'complete' && result.info === 'OK') {
						if ($.isFunction(callback)) {
							callback(result.regeocode.formattedAddress);
						}
					} else {
						callback('');
					}
				});
			});
		});
	};

	//通过浏览器获取经纬度
	sy.browserGeolocation = function(callback) {
		if (window.navigator.geolocation) {
			window.navigator.geolocation.getCurrentPosition(function(position) {
				var longt = position.coords.longitude;
				var lat = position.coords.latitude;
				survey.log('当前浏览器支持Geolocation服务，并成功返回的经度：' + longt + '，纬度：' + lat);
				callback({
					longitude: longt,
					latitude: lat
				});
			}, function(err) {
				survey.log('当前浏览器支持Geolocation服务，但是失败返回的code：' + err.code + '，message：' + err.message);
				callback('');
			});
		} else {
			survey.log('当前浏览器不支持Geolocation服务');
			callback('');
		}
	};

	//通过高德地图获取经纬度
	sy.gaodeMapGeolocation = function(callback) {
		survey.loadGaodeMaps(function(response) {
			if (!response) {
				callback('');
				return;
			}
			var map = new AMap.Map('container', {
				resizeEnable: true
			});
			map.plugin('AMap.Geolocation', function() {
				var geolocation = new AMap.Geolocation({
					enableHighAccuracy: true, //是否使用高精度定位，默认:true
					timeout: 10000, //超过10秒后停止定位，默认：无穷大
					buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
					zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
					buttonPosition: 'RB'
				});
				map.addControl(geolocation);
				geolocation.getCurrentPosition();
				//返回定位信息
				AMap.event.addListener(geolocation, 'complete', function(data) {
					var longt = data.position.getLng();
					var lat = data.position.getLat();
					survey.log('高德地图定位成功，经度：' + longt + '，纬度：' + lat + '，精度：' + data.accuracy + ' 米，是否经过偏移：' + (data.isConverted ? '是' : '否'));
					callback({
						longitude: longt,
						latitude: lat
					});
				});
				//返回定位出错信息
				AMap.event.addListener(geolocation, 'error', function(err) {
					survey.log('高德地图定位失败，失败信息是：' + typeof err === 'object' ? JSON.stringify(err) : err);
					callback('');
				});
			});
		});
	};

	//获取地理位置信息
	sy.geolocation = function(callback) {
		//首先获取浏览器的定位，异步获取
		survey.browserGeolocation(function(browserPosition) {
			if (browserPosition) {
				survey.getAddress(browserPosition, function(address) {
					browserPosition.address = address;
					survey.log('调用浏览器定位返回的信息是：' + JSON.stringify(browserPosition));
					callback(browserPosition);
				});
			} else {
				//浏览器定位不成功，则获取高德地图定位
				survey.gaodeMapGeolocation(function(position) {
					if (position) {
						survey.getAddress(position, function(address) {
							position.address = address;
							survey.log('调用高德地图定位返回的信息是：' + JSON.stringify(position));
							callback(position);
						});
					} else {
						survey.log('浏览器和高德地图都不能返回经纬度...');
						callback({
							longitude: '',
							latitude: '',
							address: '此手机不能通过浏览器和高德地图定位'
						});
						//survey.prompt('请开启地理位置信息功能');
					}
				});
			}
		});
	};

	//五秒后消失的弹出框
	sy.prompt = function(message) {
		if (!message) {
			message = '网络异常，请稍后重试...';
		}
		if ($('#_survey_ui_prompt').size() > 0) return;

		var type = "ecpic-ui-prompt";
		if ($('meta[name="viewport"]').size() > 1) {
			type += " ecpic-ui-prompt-min";
		}
		$('body').append('<div class="' + type + '" id="_survey_ui_prompt">' + message + '</div>');

		$("#_survey_ui_prompt").animate({
			opacity: 1,
			color: '#fff',
			top: 0
		}, 500, 'ease-out');

		//5秒后消失
		window.setTimeout(function() {
			$("#_survey_ui_prompt").animate({
				opacity: 0,
				color: '#000'
			}, 800, 'ease-out', function() {
				$("#_survey_ui_prompt").remove();
			});
		}, 5000);
	};

	//提示框基础类dialog
	function dialog(params) {
		var options = {
			title: "温馨提示",
			html: '',
			showHeader: true,
			showFooter: true,
			closeBtn: false,
			buttonsText: ['残忍拒绝', '我知道了'],
			callback: function(number) {}
		};
		var pa = $.extend({}, options, params);
		var txtCancel = typeof pa.buttonsText === 'string' ? pa.buttonsText : pa.buttonsText[0];
		var txtWis = typeof pa.buttonsText === 'string' ? pa.buttonsText : pa.buttonsText[pa.buttonsText.length - 1];

		if ($('#_ecpic-ui-dialog').size() === 0) {
			var tlp = [];
			tlp.push('<div class="ecpic-ui-dialog-mask" id="_ecpic-ui-dialog-mask"></div>');
			tlp.push('<div class="ecpic-ui-dialog-box" id="_ecpic-ui-dialog">');
			if (pa.showHeader) {
				tlp.push('    <div class="ecpic-ui-dialog-box-header"><strong class="ecpic-ui-dialog-box-title">' + pa.title + '</strong></div>');
			}
			tlp.push('    <div class="ecpic-ui-dialog-box-body"></div>');
			if (pa.showFooter) {
				tlp.push('    <div class="ecpic-ui-dialog-box-footer">');
				if (pa.closeBtn) {
					tlp.push('        <a href="javascript:;" class="ecpic-ui-dialog-box-footer-btn">' + txtCancel + '</a>');
				}
				tlp.push('        <a href="javascript:;" class="ecpic-ui-dialog-box-footer-btn">' + txtWis + '</a>');
				tlp.push('    </div>');
			}
			tlp.push('</div>');
			$('body').append(tlp.join(''));
		}

		var $dialog = $('#_ecpic-ui-dialog');
		$dialog.find('.ecpic-ui-dialog-box-body').html(pa.html);
		if (pa.showFooter) {
			if (pa.closeBtn) {
				//取消
				$dialog.find('.ecpic-ui-dialog-box-footer a').eq(0).on('click', function() {
					$.isFunction(pa.callback) && pa.callback(0);
					_destroy();
				});
			}
			//确认
			$dialog.find('.ecpic-ui-dialog-box-footer a').last().on('click', function() {
				$.isFunction(pa.callback) && pa.callback(1);
				_destroy();
			});
		}


		//销毁组件
		function _destroy() {
			var $dialog = $('#_ecpic-ui-dialog');
			var $dialogMask = $('#_ecpic-ui-dialog-mask');
			if ($dialog || $dialogMask) {
				window.setTimeout(function() {
					$dialog.remove();
					$dialogMask.remove();
				}, 100);
			}
		}
	}

	//弹出提示框
	sy.alert = function(o) {
		var options = {
			html: '',
			buttonsText: '我知道了',
			callback: function(number) {}
		};

		if (typeof o === 'object') {
			options = $.extend({}, options, o);
		} else {
			options.html = o;
		}
		dialog(options);
	};

	//弹出确认选择框
	sy.confirm = function(params) {
		var options = {
			html: params.html,
			closeBtn: true,
			callback: function(number) {}
		};

		var pa = $.extend({}, options, params);

		dialog(pa);
	};


	//非法请求判断
	sy.illegalEntry = function() {
		//判断流程是否完整
		/*var _re = document.referrer || '';
		if (_re) {
			//当在QQ里时，document.referrer等于当前主机名，但是这两个值又不相等，不知道怎么解决
			//统一判断是否带有上下文
			_re = _re.indexOf('wxcpic') > -1 ? 1 : '';
		}
		var _c = window.location.href.indexOf('cpic.com.cn') > -1; //排除本地开发环境

		if (_re === '' && _c) {
			window.location.replace('share.html');
		}*/
	};

	//接口地址
	sy.server = function() {
		return window.location.protocol + '//' + window.location.host + '/cpicclaim_wxh5';
	};

	//记录前端日志
	sy.webLogs = function(params) {
		var cache = survey.getLocalStorage('autoClaim.ss.caseRecord', true) || {
			caseNo: survey.getHash('caseNo') || '-'
		};
		var p = {
			url: survey.getPageName(), //当前页面名称
			type: 0, //日志类别
			content: '无内容', //日志内容
			caseNo: cache.caseNo, //案件号
			openID: 'h5' //微信唯一编号
		};
		if (typeof params === 'string') {
			p.content = params;
		} else {
			$.extend(p, params);
		}

		$.post(survey.server() + '/wx/waitAuditing/webLogs', p, function(response) {
			var res = response;
		});
	};

	//日志展示
	sy._mobileLog = function() {
		if ($('#_mobile_log_box').size() === 0) {
			var tlp = [];
			tlp.push('<div id="_mobile_log_box" class="ecpic-ui-mobile_log_box">');
			tlp.push('<ul class="ecpic-ui-mobile_log_box_ul">');
			tlp.push('	<li id="_mobile_cache_btn" class="ecpic-ui-mobile_log_box_ul_btn ecpic-ui-mobile_log_box_ul_btn_cache">清空缓存</li>');
			tlp.push('	<li id="_mobile_remove_btn" class="ecpic-ui-mobile_log_box_ul_btn ecpic-ui-mobile_log_box_ul_btn_remove">清空日志</li>');
			tlp.push('	<li id="_mobile_close_btn" class="ecpic-ui-mobile_log_box_ul_btn ecpic-ui-mobile_log_box_ul_btn_close">关闭日志</li>');
			tlp.push('</ul>');
			var style = 'height:' + ($(window).height() - 60) + 'px;';
			if ($('meta[name="viewport"]').size() > 1) {
				style += 'font-size:26px;line-height:40px;';
			}
			tlp.push('<p class="ecpic-ui-mobile_log_box_content" style="' + style + '"></p>');
			tlp.push('</div>');
			$('body').append(tlp.join(''));
			if ($('meta[name="viewport"]').size() > 1) {
				$('#_mobile_log_box').find('li').css({
					'height': '60px',
					'line-height': '60px',
					'font-size': '28px',
					'border-radius': '10px'
				});
			}
			$('#_mobile_log_box').find('p').html(sessionStorage._mobile_log || '无');
			//关闭事件
			$('#_mobile_close_btn').on('click', function() {
				$('#_mobile_log_box').remove();
			});
			//清空
			$('#_mobile_remove_btn').on('click', function() {
				sessionStorage._mobile_log = '';
				$('#_mobile_log_box').find('p').html('');
				$('#_mobile_log_box').remove();
			});
			//清缓存
			$('#_mobile_cache_btn').on('click', function() {
				alert('清理本地所有缓存，请重新登录');
				sessionStorage.clear();
				localStorage.clear();
				survey.redirection('index.html');
			});
		}
	};

	//设置页面缓存
	sy.setCache = function(key, value) {
		if (key && !value) {
			var caseRecord = survey.getLocalStorage(survey.cacheKey, true) || {};
			if (typeof key === 'object') {
				$.extend(true, caseRecord, key);
			} else {
				$.extend(true, caseRecord, {
					key: key
				});
			}
			survey.setLocalStorage(survey.cacheKey, caseRecord, true);
		}

		if (key && value) {
			survey.setLocalStorage(key, value, typeof value === 'object' ? true : false);
		}
	};

	//获取页面缓存
	sy.getCache = function(key, isjson) {
		if (!key) {
			key = survey.cacheKey;
			isjson = true;
		}
		return survey.getLocalStorage(key, isjson);
	};


	//生成随机字符串
	sy.randomName = function() {
		var len = 32;
		var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
		var maxPos = chars.length;
		var str = '';
		for (var i = 0; i < len; i++) {
			str += chars.charAt(Math.floor(Math.random() * maxPos));
		}
		return str;
	}
	
	//加密
	sy.encryptByAES = function(word) {
		var keyHex = CryptoJS.enc.Utf8.parse("%RDX6tfc5tgb^YHN");
		var encrypted = CryptoJS.AES.encrypt(word, keyHex, {
			mode: CryptoJS.mode.ECB,
			padding: CryptoJS.pad.Pkcs7
		});
		return encrypted.toString();
	};
	
	//验证特殊字符
	sy.verifySpecialCharts = function(word) {
		// var regEn = /[`~!#$^&*()_+<>?"{}.\/;'[\]]/im;
		var regEn = /[<>]/im;
		if (regEn.test(word)) {
			return true
		} else {
			return false
		}
	};


	//获取页面错误消息
	/**
	 * @param {String} errorMessage  错误信息
	 * @param {String} scriptURI   出错的文件
	 * @param {Long}  lineNumber   出错代码的行号
	 * @param {Long}  columnNumber  出错代码的列号
	 * @param {Object} errorObj    错误的详细信息，Anything
	 */
	window.onerror = function(errorMessage, scriptURI, lineNumber, columnNumber, errorObj) {
		var errorList = [];
		errorList.push('<strong style="color:red">');
		errorList.push('错误信息：' + errorMessage);
		errorList.push('出错文件：' + scriptURI);
		errorList.push('出错行号：' + lineNumber);
		errorList.push('出错列号：' + columnNumber);
		errorList.push('错误详情：' + errorObj);
		errorList.push('</strong>');
		survey.log(errorList.join(' '));
	};

	//根据不同环境显示日志按钮
	function _showLog() {
		var host = window.location.hostname.split('.');
		if (host[0] !== 'survey') {
			window.setTimeout(function() {
				var type = 'ecpic-ui_mobile_log_mark';
				if ($('meta[name="viewport"]').size() > 1) {
					type += " ecpic-ui_mobile_log_mark-min";
				}
				$('body').append('<div id="_mobile_log_mark" class="' + type + '">LOG</div>');
				//打开事件
				$('#_mobile_log_mark').on('click', function(event) {
					survey._mobileLog();
				});
			}, 1500);
		}
	}

	//自定义执行函数
	$(function() {
		//加载需要的文件
		window.setTimeout(function() {
			survey.loadFiles('../components/ui/survey.ui.css');
			survey.loadFiles('../components/ui/loading/loading.css'); //等待框样式
		}, 100);
		//显示日志
		_showLog();
		/**
		 * 不可返回的页面
		 * @type {string[]}
         */
		var notPages = ['t.html','index.html', 'revEnterIndex.html', 'revDouble.html',
			'revDouFactory.html', 'revSingleFactory.html', 'revSingle.html',
			'revExportDouCar.html', 'revExportDouCarDoc.html', 'revExportSinCar.html',
			'revPhotoGuide.html', 'banklist.html', 'mixingDouble.html', 'mixingSingle.html'
		];
		if ($.inArray(survey.getPageName(), notPages) === -1) {
			//很蛋疼，必须为popstate事件绑定加个setTimeOut。安卓某些手机浏览器进入页面会自动触发onpopstate事件
			window.setTimeout(function() {
				window.onpopstate = function(event) {
					survey.log('用户点了返回location: ' + document.location + ', state: ' + JSON.stringify(event.state));
					window.location.replace('revEnterIndex.html');
				};

				history.pushState({
					page: 1
				}, '', (window.location.href.indexOf('?') > -1 ? window.location.search + '&' : '?') + new Date().getTime());
			}, 100);

		}
	});
}(window.Zepto, survey);